package com.xiaobai.java_core.javafx;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Polygon;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;

/**
 * @Author 王天文
 * @Date 2024/12/12 16:41
 * @Description:
 */
public class ChristmasTreeJavaFX extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        Pane root = new Pane();

        // 绘制圣诞树（三角形）
        Polygon tree = new Polygon();
        tree.getPoints().addAll(
                200.0, 100.0,
                300.0, 300.0,
                400.0, 100.0
        );
        tree.setFill(Color.DARKGREEN);
        root.getChildren().add(tree);

        // 绘制树干
        Rectangle trunk = new Rectangle(300, 300, 30, 100);
        trunk.setFill(Color.SADDLEBROWN);
        root.getChildren().add(trunk);

        // 绘制一些装饰品（圆形）
        Circle ornament1 = new Circle(220, 150, 15, Color.RED);
        Circle ornament2 = new Circle(330, 200, 15, Color.YELLOW);
        Circle ornament3 = new Circle(370, 120, 15, Color.BLUE);
        root.getChildren().addAll(ornament1, ornament2, ornament3);

        Scene scene = new Scene(root, 500, 500);
        primaryStage.setTitle("Christmas Tree (JavaFX)");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
